// 统计字符串出现最多的字母
var str = "afjghdfraaaasdenas"
function findMaxDuplicateChar(str) {
  if (str.length == 1) return str
  let charObj = {}
  for (let i = 0; i < str.length; i++) {
    if (!charObj[str.charAt(i)]) {
      charObj[str[i]] = 1
    } else {
      charObj[str.charAt(i)] += 1
    }
  }
  let maxChar = '',
    maxValue = 1
  for (var key in charObj) {
    if (charObj[key] >= maxValue) {
      maxChar = key
      maxValue = charObj[key]
    }
  }
  return maxChar
}
console.log(findMaxDuplicateChar(str));

